package com.albert.utils;
import com.alibaba.druid.util.StringUtils;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtils {
    public static final String DATE = "yyyy-MM-dd";
    public static final String TIME = "yyyy-MM-dd HH:mm:ss";
    public static String dateToString(Date date, String pattern) {
        if (null != date){
            if (StringUtils.isEmpty(pattern)) {
                pattern = DATE;
            }
            SimpleDateFormat sd = new SimpleDateFormat();
            sd.applyPattern(pattern);
            return sd.format(date);
        }
        return "";
    }
}
